package com.jeomo.mem.starter.mapper;

import com.jeomo.base.starter.mapper.IBaseMapper;
import com.jeomo.mem.starter.entity.MemberPointsRuleExe;
import com.jeomo.mem.starter.entity.MemberPointsRuleList;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 会员积分规则执行单
 * @author:Jackpot
 * @create 2020-09-09 14:51
 * @description:
 */
@Mapper
public interface MemberPointsRuleExeMapper extends IBaseMapper<MemberPointsRuleExe> {

    /**
     * 根据会员等级查询所有符合要求的积分规则执行单数据
     * @param levelCodes  会员等级(多选值: v1,v2,v3)
     * @return
     */
    @Select("select rule_code,level_code,bs_code,amount_floor,points_floor  from member_points_rule_exe where LOCATE(level_code,#{levelCodes}) >0 ")
    List<MemberPointsRuleExe> getPointsRuleExesByLevels(String levelCodes);

    /**
     * 根据会员等级查询所有符合要求的积分规则执行单数据
     * @param levelCode  会员等级(单选值: v1 或 v2 或 v3)
     * @return
     */
    @Select("select rule_code,level_code,bs_code,amount_floor,points_floor  from member_points_rule_exe where level_code = #{levelCode}")
    List<MemberPointsRuleExe> getPointsRuleExesByLevel(String levelCode);

    /**
     * 根据会员等级和业务编码确定对应的唯一积分规则
     * @param levelCode
     * @param bsCode   业务编码:商品编码,商户编码,品类编码,业态编码.
     * @return
     */
    @Select("select rule_code,level_code,bs_code,amount_floor,points_floor  from member_points_rule_exe " +
            "where level_code = #{levelCode} and bs_code = #{bsCode}")
    MemberPointsRuleExe queryPointsRule(String levelCode,String bsCode);
}
